﻿using System;
using System.Collections.Generic;

namespace QuickTuner.Util
{
    public static class FrameworkExtensions
    {
        // a map function
        public static void ForEach<T>(this IEnumerable<T> @enum, Action<T> mapFunction)
        {
            foreach (var item in @enum) mapFunction(item);
        }

        // shorthand for string.Format
        public static string F(this string @string, params object[] args)
        {
            return string.Format(@string, args);
        }

        // escape the string for storing in registries
        public static string RegistryEscape(this string s)
        {
            s = s.Replace("\\", @"\\");
            s = s.Replace("\n", @"\n");
            s = s.Replace("\r", @"\r");
            s = s.Replace("\"", @"\""");

            return s;
        }
    }
}